package com.atguigu.springboot.mapper;

import com.atguigu.springboot.entities.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;

//指定这是一个操作数据库的mapper
public interface DepartmentMapper {
	
	@Select("select * from department")
	public List<Department> getDeptById();
	
	@Delete("delete from department where id=#{id}")
	public int deleteDeptById(Integer id);
	
	//options是使用主键并将数据库自动生成的主键值绑定到department对象的id上
	@Options(useGeneratedKeys = true,keyProperty = "id")
	@Insert("insert into department(departmentName) values(#{departmentName})")
	public int insertDept(Department department);
	
	@Update("update department set departmentName=#{departmentName} where id=#{id}")
	public int updateDept(Department department);

}
